package br.livro.android.cap4;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class LivroAndroidCap4Activity extends Activity {
	/** Called when the activity is first created. */
	private static final String CATEGORIA = "Livro";

	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.i(CATEGORIA, getClass().getName() + ".onCreate() Chamado: "+savedInstanceState);
        TextView t = new TextView(this);
        t.setText("Exemplo de ciclo de vida\nConsulte os logs do logCat.");
        setContentView(t);
    }
	
	protected void onStart(){
		super.onStart();
		Log.i(CATEGORIA, getClassName() + ".onStart() chamado");
	}
	
	protected void onRestart(){
		super.onRestart();
		Log.i(CATEGORIA, getClassName() + ".onRestart() chamado.");
	}
	
	protected void onResume(){
		super.onResume();
		Log.i(CATEGORIA, getClassName() + ".onResume() chamado");
	}
	
	protected void onPause(){
		super.onPause();
		Log.i(CATEGORIA, getClassName() + ".onPause() chamado");
	}
	
	protected void onStop(){
		super.onStop();
		Log.i(CATEGORIA, getClassName() + ".onStop() chamado");
	}
	
	protected void onDestroy(){
		super.onDestroy();
		Log.i(CATEGORIA, getClassName() + ".onDestroy() chamado");
	}
	
	private String getClassName(){
		//Retorna o nome da classe sem o pacote
		String s = getClass().getName();
		return s.substring(s.lastIndexOf("."));
	}
}